package com.dunqi.gpm.cangxi.WeekReport

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.widget.Toast
import com.dunqi.gpm.cangxi.R
import com.dunqi.gpm.cangxi.WeekReport.Model.WeekChekModel
import com.dunqi.gpm.cangxi.WeekReport.Model.WeekPlan
import com.dunqi.gpm.cangxi.WeekReport.Model.WeekReport
import com.dunqi.gpm.cangxi.WeekReport.WeekChek.WeekCheckDetail.WeekCheckDetailFragment
import com.dunqi.gpm.cangxi.WeekReport.WeekPlan.WeekPlanDetail.WeekPlanDetailFragment
import com.dunqi.gpm.cangxi.WeekReport.WeekReport.WeekReportDetail.WeekReportDetailFragment
import com.dunqi.gpm.cangxi.WeekReport.WeekSet.WeekPeportSetDetailFragment

class WeekDetailControlerActivity : AppCompatActivity() {
    var item: Any? = null
    var flag: Int = 0
    var flag_checktype: Int = 0
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_week_detail)
        item = intent.getSerializableExtra("object")
        flag = intent.getIntExtra("type", 0)
        flag_checktype = intent.getIntExtra("flag_checktype", WeekCheckDetailFragment.LookInfo)//只有周报审核有
        if (flag == 0) {
            Toast.makeText(this@WeekDetailControlerActivity, "出入正确参数!", Toast.LENGTH_SHORT).show()
            return
        }
        when (flag) {
            1 -> {//周报配置
                supportFragmentManager.beginTransaction().replace(R.id.week_detail_container, WeekPeportSetDetailFragment.newInstance("", "")).commit()
            }
            2 -> {//周计划
                supportFragmentManager.beginTransaction().replace(R.id.week_detail_container, WeekPlanDetailFragment.newInstance(item as WeekPlan?, "")).commit()
            }
            3 -> {//周报告
                supportFragmentManager.beginTransaction().replace(R.id.week_detail_container, WeekReportDetailFragment.newInstance(item as WeekReport?, "")).commit()
            }
            4 -> {//周报审核
                supportFragmentManager.beginTransaction().replace(R.id.week_detail_container, WeekCheckDetailFragment.newInstance(item as WeekChekModel?, flag_checktype)).commit()
            }
        }
    }
}
